package com.example.boot_web.controller;

import com.example.boot_web.model.User;
import com.example.boot_web.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * ClassName: UserController
 * Package: com.example.boot_web.controller
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-05-16
 * Time: 12:13
 */
@RestController
public class UserController {

    @Autowired
    private UserService userService;

    //Model参数 可以存放数据 放到request作用域
    //返回值 String 表示试图
    @GetMapping("/list")
    public String hello(Model model){
        List<User> list = userService.list();
        model.addAttribute("list",list);
        return "list";
    }
}
